package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppMingXiTx;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author anxiang
 * @version 1.0.0
 * @ClassName AfterMingXiTxDao.java
 * @Description 提现明细记录
 * @createTime 2021年11月02日 14:55:00
 */
@Repository
public class AfterMingXiTxDao extends BaseDao<AppMingXiTx> {

    /**
     * 新增或更新
     * @param appMingXiTx
     */
    public void saveOrUpdate(AppMingXiTx appMingXiTx) {
        if (appMingXiTx.getId() == null || appMingXiTx.getId() == 0) {
            appMingXiTx.setId(this.add(appMingXiTx));
        } else {
            this.update(appMingXiTx);
        }
    }

    /**
     * 综合查询
     * @param userid
     * @param splitPageBean
     * @return
     */
    public List<AppMingXiTx> findList(String userid, SplitPageBean splitPageBean) {
        List<Object> list = new ArrayList<>();
        StringBuilder str = new StringBuilder();
        str.append("select * from app_mingxi_tx where 1=1 ");
        if (StringEx.isNotNull(userid)) {
            str.append(" and userid = ? ");
            list.add(userid);
        }
        str.append(" order by createtime desc ");
        String sql = str.toString();
        return this.queryList(sql, list, AppMingXiTx.class, splitPageBean);
    }

}